package com.rainbow.support.mybatis.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.Instant;

/**
 * 统一数据库存储基类
 * @author 付为地
 **/
@Data
@ApiModel("基础类")
@NoArgsConstructor
@AllArgsConstructor
public class BaseEntity implements Serializable {


    public static final String CREATOR = "creator";
    public static final String CREATE_TIME = "createTime";
    public static final String LOGIC_DELETE = "logicDelete";
    public static final String UPDATER = "updater";
    public static final String UPDATE_TIME = "updateTime";

    /**
     * 创建人
     */
    @ApiModelProperty("创建人")
    @TableField(fill = FieldFill.INSERT)
    private String creator;
    /**
     * 更新人
     */
    @ApiModelProperty("更新人")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updater;

    /**
     * 删除标志:false:未删除,true:已删除
     */
    @TableField(fill = FieldFill.INSERT)
    @TableLogic(value = "false", delval = "true")
    @ApiModelProperty("删除标志:false:未删除,true:已删除")
    private Boolean logicDelete;

    /**
     * MP 版本 3.4.3.x 支持 @OrderBy
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty("创建时间")
    /*@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")*/
    private Instant createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    /*@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")*/
    private Instant updateTime;


}
